import { WorkbenchStateInterface } from 'src/store/workbench/state'
import { WidgetStateInterface } from 'src/store/widget/state'
import { ToolStateInterface } from 'src/store/tool/state'

export type UserInfo = {
  _id: string,
  name: string,
  toolLike?: string[],
  toolCollection?: string[],
  toolForward?: string[],
  contentVote?: string[],
  contentCollect?: string[],
  contentForward?: string[],
  role?: number,
  data?: unknown
}

export interface StateInterface {
  userInfo: UserInfo,
  workbench: WorkbenchStateInterface,
  widget: WidgetStateInterface,
  tool: ToolStateInterface,
  workbenches: {
    id: string,
    name: string,
  }[],
  // 默认为 'main'
  // main 为主面板，不可删除
  currentWorkbenchId: string,
  // 分享面板 ID
  shareId: string | null
  sharePanelInfo: {
    userName: string,
    userId: string
  }
}

function state (): StateInterface {
  return Object.assign({
    userInfo: {
      _id: '',
      name: '',
      toolLike: [],
      toolCollection: [],
      contentVote: [],
      role: 99
    },
    workbenches: [],
    currentWorkbenchId: 'main',
    shareId: null
  })
}

export default state
